package com.wltjack.service.impl;

import com.wltjack.dao.User4JpaDao;
import com.wltjack.dao.model.User;
import com.wltjack.service.User4JpaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class User4JpaServiceImpl implements User4JpaService {
    @Autowired
    private User4JpaDao user4JpaDao;

    @Override
    public List<User> findAll() {
        List<User> userList = user4JpaDao.findAll();
        return userList;
    }

    @Override
    public Page<User> getPage(Integer pageNo,Integer pageSize){
        Page<User> userPage = user4JpaDao.findAll(PageRequest.of(pageNo, pageSize));
        return userPage;
    }

    @Override
    public Page<User> searchUser(Integer pageNo, Integer pageSize, String searchText){
        Page<User> userPage = user4JpaDao.search(searchText, PageRequest.of(pageNo, pageSize));
        return userPage;
    }
}
